# -*- coding: utf-8 -*-
""" 
@author: ertao.xyz
@create: 2021-12-29 16:56
@description: 
"""
from typing import Type, Optional, List
from pydantic import Field

from tortoise import fields, Model
from tortoise.contrib.pydantic import pydantic_model_creator

from core.model import AbstractBaseModel, TimestampMixin


class Files(TimestampMixin, AbstractBaseModel):
    user = fields.ForeignKeyField('models.User', description='所属用户')
    nickname = fields.CharField(max_length=32, description='昵称', null=True, default=None)
    filename = fields.CharField(max_length=32, description='文件名', unique=True)
    save_dir = fields.CharField(max_length=64, description='文件目录', unique=True)
    url = fields.CharField(max_length=128, description='文件名', unique=True)

    def __str__(self):
        return self.filename

    class Meta:
        table = 'files'
        ordering = ['-id']
        table_description = '文件表'
